package com.ss.SmartStock.pojo.vo;

import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ss.SmartStock.common.PageRequest;
import com.ss.SmartStock.pojo.entity.Product;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 商品信息查询请求
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class ProductQueryVO extends PageRequest implements Serializable {

    /**
     * 权益ID
     */
    private Integer raiType;

    /**
     * 商品名称
     */
    private String productName;


    /**
     * 库存
     */
    private Integer inStock;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime timeOn;


    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime timeOff;


    /**
     * 商品状态
     */
     private Integer product_online_state;

    /**
     * 管理人
     */
    private Long operator;



    private static final long serialVersionUID = 1L;


    /**
     * 对象转包装类
     *
     * @param product
     * @return
     */
    public static ProductQueryVO objToVo(Product product) {
        if (product == null) {
            return null;
        }
        ProductQueryVO productQueryVO = new ProductQueryVO();
        BeanUtils.copyProperties(product, productQueryVO);

        return productQueryVO;
    }
}